from django.db import models

class Book(models.Model):
    id = models.AutoField(primary_key=True)
    title = models.CharField(max_length=100, verbose_name="书名")  # 字符串类型，最长100字符
    author = models.CharField(max_length=50, verbose_name="作者")  # 作者名
    publish_date = models.DateField(verbose_name="出版日期")       # 日期类型

    def __str__(self):
        return self.title  # 打印对象时显示书名

# 新增Author模型
class Author(models.Model):
    name = models.CharField(max_length=50, verbose_name="姓名")
    bio = models.TextField(verbose_name="简介", blank=True)
    birth_date = models.DateField(verbose_name="出生日期", null=True, blank=True)
    created_at = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    updated_at = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    def __str__(self):
        return self.name